﻿using FourGroups.Project;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WMS.Seven.Models;
using WMSProject.ChuBoWen;

namespace WMSProject.Web.Controllers
{
    public class ChuBoWenController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        
        #region /// 引用服务
        public readonly UnitsManagerService _unitsManagerService;
        private readonly SalesService _salesRepository;
        public ChuBoWenController(UnitsManagerService unitsManagerService, SalesService salesRepository)
        {
            _unitsManagerService = unitsManagerService;
            _salesRepository = salesRepository;
        }
        #endregion

        #region /// 单位管理器
        public IActionResult UnitsManagerView()
        {
            return View();
        }
        public IActionResult AddUnitsManagerView()
        {
            return View();
        }
        public IActionResult UpdUnitsManager()
        {
            return View();
        }
        /// <summary>
        /// 获取单位管理信息
        /// </summary>
        /// <param name="unitNumber">单位编码</param>
        /// <param name="unitName">单位名称</param>
        /// <returns>返回单位管理信息的泛型集合</returns>
        public async Task<InterSelect<object>> GetUnitsManagerList(string? unitNumber, string? unitName, int pageIndex, int pageSize)
        {
            var unitsManagers = await _unitsManagerService.GetUnitsManagerList(unitNumber, unitName, pageIndex, pageSize);
            return unitsManagers;
        }

        /// <summary>
        /// 新增单位
        /// </summary>
        /// <param name="unitsManager"></param>
        /// <returns></returns>
        public async Task<int> AddUnitsManager(UnitsManager unitsManager)
        {
            var result = await _unitsManagerService.AddUnitsManager(unitsManager);
            return result;
        }

        /// <summary>
        /// 删除单位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<int> DeleteUnitsManager(int id)
        {
            var result = await _unitsManagerService.DeleteUnitsManager(id);
            return result;
        }

        /// <summary>
        /// 获取单位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<UnitsManager> GetUnitsManager(int id)
        {
            var result = await _unitsManagerService.GetUnitsManager(id);
            return result;
        }

        /// <summary>
        /// 修改单位
        /// </summary>
        /// <param name="unitsManagerDTO"></param>
        /// <returns></returns>
        public async Task<int> UpdateUnitsManager(UnitsManagerDTO unitsManagerDTO)
        {
            var result = await _unitsManagerService.UpdateUnitsManager(unitsManagerDTO);
            return result;
        }
        #endregion

        #region /// 仓库管理器

        public IActionResult SalesView()
        {
            return View();
        }
        public IActionResult SalesOrderAdd()
        {
            return View();
        }
        /// <summary>
        /// 获取销售列表
        /// </summary>
        /// <returns></returns>
        public async Task<object> GetSalesList(string? salesOrderCode, string? productCode, string? productName)
        {
            var salesList = await _salesRepository.GetSalesList(salesOrderCode, productCode, productName);
            return salesList;
        }
        /// <summary>
        /// 获取产品
        /// </summary>
        /// <param name="code"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public async Task<object> GetProduct(RequestProductDTO productDTO)
        {
            var productList = await _salesRepository.GetProduct(productDTO);
            return productList;
        }
        #endregion
    }
}
